<template>
	<view class="addSalesman">
		<u-navbar
			title="新增业务员" 
			left-text="" 
			@leftClick="onClickBack"
			:placeholder="true"
			:fixed="true"
			:safeAreaInsetTop="true"
		></u-navbar>
		<view class="content">
			<u--form
				labelPosition="left"
				:model="formData"
				ref="form1" >
				<u-form-item
					label="登录账号"
					prop="account"
					borderBottom
					labelWidth="100"
					clearable
					ref="item1">
					<u--input v-model="formData.account" border="none" placeholder="请输入8~20位数字或字母"></u--input>
				</u-form-item>
				<u-form-item
					label="登录密码"
					prop="password"
					borderBottom
					labelWidth="100"
					clearable
					ref="item1">
					<u--input v-model="formData.password" :type="inputType" border="none" placeholder="请输入8~20位数字或字母"></u--input>
					<u-icon name="eye" color="#2979ff" slot="right" @click="seePwd"></u-icon>
				</u-form-item>
				<u-form-item
					label="业务员姓名"
					prop="name"
					borderBottom
					labelWidth="100"
					clearable
					ref="item1">
					<u--input v-model="formData.name" border="none" placeholder="请输入业务员姓名"></u--input>
				</u-form-item>
				<u-form-item
					label="业务员手机"
					prop="phone"
					borderBottom
					labelWidth="100"
					clearable
					ref="item1">
					<u--input v-model="formData.phone" border="none" placeholder="请输入手机号"></u--input>
				</u-form-item>
				
			</u--form>
		</view>
		<view class="m20">
			<u-button type="primary" text="提交" @click="submit"></u-button>
		</view>
		<u-toast ref="uToast"></u-toast>
	</view>
</template>

<script>
export default {
	data() {
		return {
			formData: {
				account: '',
				password: '',
				name: '',
				phone: ''
			},
			inputType: 'text'
		}
	},
	methods: {
		// 返回页面
		onClickBack () {
			uni.navigateBack()
		},
		seePwd () {
			this.inputType === 'password'?this.inputType = 'text':this.inputType = 'password';
		},
		submit () {
			if (this.formData.account === '') {
				this.$refs.uToast.show({
					type: 'default',
					title: '默认主题',
					message: "请输入登录账号",
				})
				return
			}
			if (this.formData.password === '') {
				this.$refs.uToast.show({
					type: 'default',
					title: '默认主题',
					message: "请输入登录密码",
				})
				return
			}
			if (this.formData.phone === '') {
				this.$refs.uToast.show({
					type: 'default',
					title: '默认主题',
					message: "请输入业务员手机号",
				})
				return
			}
			if (this.formData.name === '') {
				this.$refs.uToast.show({
					type: 'default',
					title: '默认主题',
					message: "请输入业务员姓名",
				})
				return
			}
		}
	}
}
</script>

<style lang="scss" scoped>
	.content {
		margin-top: 20rpx;
		background: #FFFFFF;
		padding: 0 20rpx;
	}

</style>
